drop table if exists ustore_primary_key_deferrable;
create table ustore_primary_key_deferrable
(
    c1 int,
    constraint ustore_primary_key_deferrable_pkey primary key (c1) deferrable
) with (storage_type = 'ustore');
insert into ustore_primary_key_deferrable values(1);

-- 约束生效
insert into ustore_primary_key_deferrable values(1);

-- 去除列约束正常插入
alter table ustore_primary_key_deferrable drop constraint if exists ustore_primary_key_deferrable_pkey;
insert into ustore_primary_key_deferrable values(1);

-- 有不符合条件数据时无法添加列约束
alter table ustore_primary_key_deferrable add constraint ustore_primary_key_deferrable_pkey primary key (c1) deferrable;

-- 删除重复数据添加列约束成功
delete from ustore_primary_key_deferrable where c1 = 1;
alter table ustore_primary_key_deferrable add constraint ustore_primary_key_deferrable_pkey primary key (c1) deferrable;
insert into ustore_primary_key_deferrable values(1);

begin;
set constraints all deferred;
insert into ustore_primary_key_deferrable values(1);
end;

begin;
set constraints all immediate;
insert into ustore_primary_key_deferrable values(1);
end;

begin;
set constraints all deferred;
insert into ustore_primary_key_deferrable values(1);
set constraints all immediate;
end;

drop table ustore_primary_key_deferrable;